import request from '@/utils/request'

// 查询采购退货单明细列表
export function listReturnItem(query) {
  return request({
    url: '/purchase/returnItem/list',
    method: 'get',
    params: query
  })
}

// 查询采购退货单明细详细
export function getReturnItem(itemId) {
  return request({
    url: '/purchase/returnItem/' + itemId,
    method: 'get'
  })
}

// 新增采购退货单明细
export function addReturnItem(data) {
  return request({
    url: '/purchase/returnItem',
    method: 'post',
    data: data
  })
}

// 修改采购退货单明细
export function updateReturnItem(data) {
  return request({
    url: '/purchase/returnItem',
    method: 'put',
    data: data
  })
}

// 删除采购退货单明细
export function delReturnItem(itemId) {
  return request({
    url: '/purchase/returnItem/' + itemId,
    method: 'delete'
  })
}

// 根据退货单ID查询明细列表（修正API路径）
export function listReturnItemByReturnId(returnId) {
  return request({
    url: '/purchase/returnItem/return/' + returnId,
    method: 'get'
  })
}

// 根据物料编码查询退货明细
export function listReturnItemByMaterialCode(materialCode) {
  return request({
    url: '/purchase/returnItem/material/' + materialCode,
    method: 'get'
  })
}

// 根据批次号查询退货明细
export function listReturnItemByBatchCode(batchCode) {
  return request({
    url: '/purchase/returnItem/batch/' + batchCode,
    method: 'get'
  })
}

// 批量新增采购退货单明细
export function batchAddReturnItem(data) {
  return request({
    url: '/purchase/returnItem/batchAdd',
    method: 'post',
    data: data
  })
}

// 根据退货单ID删除明细
export function delReturnItemByReturnId(returnId) {
  return request({
    url: '/purchase/returnItem/deleteByReturnId/' + returnId,
    method: 'delete'
  })
}